<template>
    <div style="padding: 15px;">
        <el-table :data="tableData" style="width: 100%" >
            <el-table-column prop="username" label="用户名"  />
            <el-table-column prop="phone" label="电话" />
            <el-table-column prop="address" label="居住地址" />
            <el-table-column prop="email" label="邮件地址" />
            <el-table-column prop="roleName" label="申请角色"  />
            <el-table-column prop="permission" label="通过"  />
            <el-table-column prop="operate" label="操作" width="200px">
<!--                <el-button type="success">通过</el-button>-->
<!--                <el-popconfirm title="确认同意">-->
<!--                    <template #default="scope">
                        <el-button style="font-weight: bold;" size="small" type="success" @click="handleDelete(scope.$index, scope.row)" :icon="Delete"></el-button>
                    </template>-->
                    <template #default="scope" >
                        <el-button @click="OkRegister(scope.$index, scope.row)" style="font-weight: bold;" size="small" type="success">通过</el-button>
                    </template>
<!--                </el-popconfirm>-->
            </el-table-column>
        </el-table>
    </div>
</template>

<script setup>
    import {Search,Refresh,Plus,Delete,EditPen} from '@element-plus/icons-vue'
    import {ref} from "vue";
    import {get, post} from "@/net";
    import {ElMessage} from "element-plus";

    get("/user/registerApp",((data)=>{
        console.log(data)
        tableData.value=data
    }),(data)=>{
        console.log(data)
        console.log('失败了')
    })


    const OkRegister=(index,row)=>{
        console.log('data::')
        console.log(row.username)
        post('/user/OkRegisterApp',row.username,((data)=>{
            ElMessage.success('批准')
            get("/user/registerApp",((data)=>{
                console.log(data)
                tableData.value=data
            }),(data)=>{
                console.log(data)
                console.log('失败了')
            })
        }),((data)=>{
            ElMessage.warning('错误')
        }))
    }

    const tableData= ref([{}])
</script>

<style scoped>

</style>